<!--- ========================================================================== --->
<!--- Group Approval :: Add Employees                                            --->
<!--- by Maan 11302007 (part of Group Approval eTask application)                --->
<!--- ========================================================================== --->
<CFOUTPUT>
	<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TITLE = "Add Employees">
	<CFQUERY NAME="qryCMFPAFIELDS" DATASOURCE="#client.global_dsn#">
		SELECT COLUMNDESC, COLUMNNAME FROM GRGBOSETABLEFIELDS
		WHERE TABLENAME = 'CMFPA' AND HIDEONBROWSE = 'N'
		ORDER BY COLUMNORDER
	</CFQUERY>
	<CFIF qryCMFPAFIELDS.RECORDCOUNT>
		<CFIF isDefined("form.EDTBATCHNUMBER")>
			<CFSET URL.Docnumber = form.EDTBATCHNUMBER>
		<CFELSEIF isDefined("form.HIDDOCNUMBER")>
			<CFSET URL.Docnumber = form.HIDDOCNUMBER>
		</CFIF>
		<CFSET arrFields = ArrayNew(1)>
		<!--- get fields for filter --->
		<CFQUERY NAME="qryFilterFlds" DATASOURCE="#client.global_dsn#">
			SELECT FIELDNAME
			FROM EGRGUSERGROUPSSTAT
			WHERE TABLENAME = 'CMFPA'
		</CFQUERY>
		<!--- get creator info for filtering --->
		<CFQUERY NAME="qryCreatorInfo" DATASOURCE="#client.company_dsn#">
			SELECT #ValueList(qryFilterFlds.FIELDNAME)# 
			FROM CMFPA
			WHERE GUID = '#client.guid#'
		</CFQUERY>
		<CFQUERY NAME="qryCMFPA" DATASOURCE="#client.global_dsn#">
			SELECT B.USERID, #ValueList(qryCMFPAFIELDS.COLUMNNAME,",A.")#, A.PERSONNELIDNO AS PERSONNELIDNO, A.PERSONNELBADGENO FROM #client.company_dsn#..CMFPA A, EGRGUSERMASTER B
			WHERE 	(A.GUID = B.GUID) 
				<CFIF isDefined("url.paramsubcompany") AND decrypt(url.paramsubcompany,client.ek) EQ "Y">
					AND (A.SUBCOMPANYCODE = '#client.subcompany_code#')
				</CFIF>
				AND (A.EMPLOYMENTSTATUS='REGULAR' OR A.EMPLOYMENTSTATUS='PROBATIONARY')
				AND #stheID# NOT IN (SELECT PERSONNELIDNO FROM #client.company_dsn#..ECINBATCHEMPS WHERE BATCHID = '#getform.formcode#' AND DOCNUMBER = '#URL.Docnumber#')
				<!--- Revised by Maan: 02172008 <CFIF isDefined("form.selGroupCodes") AND form.selGroupCodes NEQ "">AND #ListGetAt(Form.selGroup,2,"~")# = '#form.selGroupCodes#'</CFIF>--->
				<CFIF Trim(GetData.FLDFILTER) NEQ "">
					<CFLOOP LIST="#GetData.FLDFILTER#" INDEX="xflter">
						AND (#xflter# = '#evaluate("qryCreatorInfo." & xflter)#')
					</CFLOOP>
				</CFIF>
				ORDER BY A.LASTNAME
			</CFQUERY>
		<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=3 BGCOLOR="#client.color_grphead#" WIDTH="100%">
			<TR>
				<TD colspan=3>
					<INPUT TYPE="SUBMIT" NAME="btnAddEmps" VALUE = "Add Selected" CLASS="bitbtn"<CFIF qryCMFPA.RECORDCOUNT EQ 0>DISABLED</CFIF>>&nbsp;
					<INPUT TYPE="button" NAME="btnBack" VALUE = "Back" CLASS="bitbtn" onclick="javascript: window.location.href=window.location.href;">&nbsp;
					<INPUT TYPE="hidden" NAME="hidDocnumber" VALUE="#URL.Docnumber#">
					<INPUT TYPE="hidden" NAME="hidBatchDesc" <CFIF isDefined("form.edtBatchDesc")>VALUE="#form.edtBatchDesc#"</CFIF>
				</TD> 
				<!--- removed by Maan: 02172008
				<TD colspan=1 ALIGN="right">
					<font color="white">Display by Group:</font>
					<SELECT NAME="selGroup" STYLE="width: 130px" onChange="javascript:document.frmBatchApp.submit();">
						<OPTION VALUE="">&nbsp;--- select group ---</OPTION>
						<CFQUERY NAME="qryGrpStatus" DATASOURCE="#client.global_dsn#">
							SELECT TABLENAME, FIELDNAME
							FROM EGRGUSERGROUPSSTAT
						</CFQUERY>
						<CFIF qryGrpStatus.RECORDCOUNT NEQ 0>
							<CFLOOP QUERY="qryGrpStatus">
								<OPTION VALUE="#TABLENAME#~#FIELDNAME#" <CFIF isDefined("Form.selGroup") AND ListGetAt(Form.selGroup,2,"~") EQ "#FIELDNAME#">SELECTED</CFIF>>&nbsp;#FIELDNAME#</OPTION>
							</CFLOOP>
						</CFIF>
					</SELECT>
					
					<SELECT NAME="selGroupCodes" STYLE="width: 130px" onChange="javascript:document.frmBatchApp.submit();">
						<OPTION VALUE="">&nbsp;--- select code ---</OPTION>
						<CFIF isDefined("Form.selGroup") AND Form.selGroup NEQ "">
							<CFQUERY NAME="qryCMFPAGroup" DATASOURCE="#client.company_dsn#">
								SELECT DISTINCT(#ListGetAt(Form.selGroup,2,"~")#) AS GROUPNAME
								FROM #ListGetAt(Form.selGroup,1,"~")# WHERE (#ListGetAt(Form.selGroup,2,"~")# <> '')
							</CFQUERY>
							<CFLOOP QUERY="qryCMFPAGroup">
								<OPTION VALUE="#GROUPNAME#" <CFIF isDefined("form.selGroupCodes") AND form.selGroupCodes EQ "#GROUPNAME#">SELECTED</CFIF>>&nbsp;#GROUPNAME#</OPTION>
							</CFLOOP>
						</CFIF>
					</SELECT>
				</TD>
				--->
			</TR>
		</TABLE>
		<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=0 WIDTH="100%">
			<TR BGCOLOR="#client.color_tblhead#">
				<TD><center><INPUT TYPE="CHECKBOX" NAME="chkAll" ONCLICK="javascript:chkBoxAllEmps(document.frmBatchApp.chkEmp);"></center></TD>
				<TD CLASS="boldwhite">&nbsp;Userid</TD>
				<CFIF qryCMFPA.RECORDCOUNT>
					<CFSET x = 0>
					<CFLOOP QUERY="qryCMFPAFIELDS">
						<TD CLASS="boldwhite">&nbsp;#COLUMNDESC#</TD>
						<CFSET x = x + 1>
						<CFSET arrFields[x] = COLUMNDESC>
					</CFLOOP>
			</TR>
					<CFLOOP QUERY="qryCMFPA">
						<TR BGCOLOR=<CFIF CurrentRow Mod 2>"#client.color_tblset2#"<CFELSE>"#client.color_tblset1#"</CFIF> VALIGN="top">
							<TD>
								&nbsp;&nbsp;<INPUT TYPE="CHECKBOX" NAME="chkEmp"VALUE="#evaluate("qryCMFPA." & stheID)#~#URL.Docnumber#">
							</TD>
							<TD>
								&nbsp;&nbsp;#USERID#
							</TD>
							<CFLOOP INDEX="i" FROM="1" TO="#x#">
								<TD>
									&nbsp;&nbsp;#evaluate("qryCMFPA." & arrFields[i])#
								</TD>
							</CFLOOP>
					</CFLOOP>
				</CFIF>
			</TR>
			<CFSET nCols = ListLen(ValueList(qryCMFPAFIELDS.COLUMNNAME)) + 2>
			<TR BGCOLOR="#client.color_tblfoot#">
				<TD CLASS="boldwhite" HEIGHT=18 COLSPAN="#nCols#">&nbsp;&nbsp;#qryCMFPA.RECORDCOUNT# record(s) found.</TD>
			</TD>
	<CFELSE>
		<CFSET sWarn="CMFPA is not properly configured.<br>Please check Data Architect."><!--- ELSE --- THERE IS NO FIELDS IN CMFPA FOR BROWSING --->
	</CFIF>	
	</TABLE>
	<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TOP="False">
</CFOUTPUT>
